package com.example.take_out_dish.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.take_out_dish.entity.SetmealDish;
import com.example.take_out_dish.mapper.SetmealDishMapper;
import com.example.take_out_dish.service.SetmealDishService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 套餐菜品关系 服务实现类
 * </p>
 */
@Service
@Slf4j
public class SetmealDishServiceImpl extends ServiceImpl<SetmealDishMapper, SetmealDish> implements SetmealDishService {

    @Resource
    private SetmealDishMapper setmealDishMapper;

    @Override
    public void insertBatch(List<SetmealDish> source) {
        this.saveBatch(source);
    }

    @Override
    public void deleteBatchBySetmealId(List<String> ids) {
        baseMapper.delete(new LambdaQueryWrapper<SetmealDish>()
                .in(SetmealDish::getSetmealId,ids));
    }

    /**
     * 根据套餐id查询套餐与菜品关系数据
     * @param id
     * @return
     */
    @Override
    public List<SetmealDish> selectBySetmealId(String id) {
        return setmealDishMapper.selectList(new LambdaQueryWrapper<SetmealDish>()
                .eq(SetmealDish::getSetmealId,id));
    }
}
